package com.alan.wifishare.view.ui;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alan.wifishare.R;

/**
 * @className: ALListViewDialog
 * @describtion: ALListViewDialog
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/5/4 11:39
 */
public class ALListViewDialog extends Dialog {

    private TextView titleTv;
    private ListView listView;
    private RelativeLayout bottomBtn;
    private TextView btnTextView;

    public ALListViewDialog(Context context) {
        super(context);
        initView(context);
    }

    public ALListViewDialog(Context context, int themeResId) {
        super(context, themeResId);
        initView(context);
    }

    protected ALListViewDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initView(context);
    }


    private void initView(Context context) {
        this.setContentView(R.layout.al_listview_dialog_layout);
        titleTv = (TextView)this.findViewById(R.id.alListViewDialogTitleTv);
        listView = (ListView)this.findViewById(R.id.alListViewDialogList);
        bottomBtn = (RelativeLayout)this.findViewById(R.id.alListViewDialogBtn);
        btnTextView = (TextView)this.findViewById(R.id.alListViewDialogBottomBtnTv);
    }


    public void setTitleText(String title){
        titleTv.setText(title);
    }

    public void setBottomBtnTextWithClickListener(String btnText, View.OnClickListener onClickListener){
        btnTextView.setText(btnText);
        bottomBtn.setOnClickListener(onClickListener);
    }

    public void setListAdapter(BaseAdapter baseAdapter){
        listView.setAdapter(baseAdapter);
    }

    public void setListOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener){
        listView.setOnItemClickListener(onItemClickListener);
    }
}
